@extends('common')
@section('content')
    <form action="{{ url('/execu/updateInfoPro')}}" method="post" class="definewidth m20" enctype="multipart/form-data">
        <input type="hidden" name="_token" value="{{ csrf_token() }}" />
        <input type="hidden" name="h_id" value="{{$stu_info['stu_id']}}">
        <table style="width:80%;float: left" class="table table-bordered table-hover m10">
            <tr>
                <td class="tableleft">编号</td>
                <td><input type="text" id="use_num" required="required" pattern="^XY\d{8}$" name="use_num" value="{{$stu_info['use_num']}}"/></td>
            </tr>
            <tr>
                <td class="tableleft">姓名</td>
                <td><input type="text" pattern="^[\u4e00-\u9fa5]{2,17}$" required name="use_name" value="{{$stu_info['use_name']}}"/></td>
            </tr>
            <tr>
                <td class="tableleft">性别</td>
                <td><select name="use_sex" style="width:150px">
                        @if($stu_info['use_sex']==1)
                        <option value="1" selected>男</option>
                        <option value="2">女</option>
                        @else
                        <option value="1">男</option>
                        <option value="2" selected>女</option>
                        @endif
                    </select>
                </td>
            </tr>
            <tr>
                <td class="tableleft">身份证号</td>
                <td><input type="text" id="use_card" pattern="^((\d{15})|(\d{17}[0-9X]))$" required name="use_card" value="{{$stu_info['use_card']}}" /></td>
            </tr>
            <tr>
                <td class="tableleft">联系电话</td>
                <td><input type="text" pattern="^1[3-9]\d{9}$" required name="use_phone" value="{{$stu_info['use_phone']}}"/></td>
            </tr>
            <tr>
                <td class="tableleft">车型</td>
                <td><select name="per_id">
                        @foreach($pap_info as $v)
                            @if($stu_info['per_id']==$v['pap_id'])
                            <option value="{{$v['pap_id']}}" selected >{{$v['pap_name']}}</option>
                            @else
                                <option value="{{$v['pap_id']}}">{{$v['pap_name']}}</option>
                            @endif
                        @endforeach
                    </select>
                </td>
            </tr>
            <tr>
                <td class="tableleft">学习阶段</td>
                <td><select name="sub_id">
                    @foreach($sub_info as $v)
                        @if($stu_info['sub_id']==$v['sub_id'])
                        <option value="{{$v['sub_id']}}" selected >{{$v['sub_name']}}</option>
                        @else
                        <option value="{{$v['sub_id']}}">{{$v['sub_name']}}</option>
                        @endif

                    @endforeach
                    </select>
                </td>
            </tr>
            <tr>
                <td class="tableleft">报名时间</td>
                <td><input type="text" id="indate"  pattern="^\d{4}-\d{2}-\d{2}$" required name="use_enty" value="{{$stu_info['use_enty']}}"/></td>
            </tr>
            <tr>
                <td class="tableleft">状态</td>
                <td><select name="stu_state">
                    @foreach($sta_info as $v)
                        @if($stu_info['stu_state']==$v['ust_id'])
                        <option value="{{$v['ust_id']}}" selected>{{$v['ust_state']}}</option>
                        @else
                        <option value="{{$v['ust_id']}}">{{$v['ust_state']}}</option>
                        @endif
                    @endforeach
                    </select>
                </td>
            </tr>
            <tr>
                <td class="tableleft"></td>
                <td>
                    <button type="submit" class="btn btn-primary" type="button">保存</button> &nbsp;&nbsp;<button type="button" class="btn btn-success">取消</button>
                </td>
            </tr>

        </table>
    </form>
    <script src="{{url('api/jedate/jedate.js')}}"></script>
    <script type="text/javascript">
        jeDate({
            dateCell:"#indate",
            format:"YYYY-MM-DD",
            isinitVal:true,
            isTime:true, //isClear:false,
            minDate:"2000-01-01",
            okfun:function(val){alert(val)}
        })
        $("#use_num").blur(function(){
            var num=$(this).val();
            var url="{{ url('execu/checkNum') }}";
            $.get(url, { num: num},
                    function(data){
                        if(data==1)
                        {
                            alert("编号已存在");
                            $("#sub").attr('disabled','true');                                       }
                        else if(data==2)
                        {
                            $("#sub").removeAttr('disabled');
                        }
                    });
        })
        $("#use_card").blur(function(){
            var card=$(this).val();
            var url="{{ url('execu/checkCard') }}";
            $.get(url, { card: card},
                    function(data){
                        if(data==1)
                        {
                            alert("该用户已存在，请填写正确的身份证号");
                            $("#sub").attr('disabled','true');                                       }
                        else if(data==2)
                        {
                            $("#sub").removeAttr('disabled');
                        }
                    });
        })
    </script>
@stop